var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BundleManager = require("BundleManager");
var $2kc = require("kc");
var $2pvzChannel = require("pvzChannel");
var $2pvzHtItem = require("pvzHtItem");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_pvzHtBoxView = /* */function (_cc$Component88) {
  babel_inherits(d, _cc$Component88);
  var _super122 = babel_createSuper(d);
  function d() {
    var _this291;
    babel_classCallCheck(this, d);
    _this291 = _super122.apply(this, arguments);
    _this291.close = null;
    _this291.container = null;
    _this291.container2 = null;
    _this291.moveSpeed = 1;
    _this291.isMoving = false;
    _this291.spMap = new Map();
    _this291.iconArr = null;
    return _this291;
  }
  babel_createClass(d, [{
    key: "onLoad",
    value: function onLoad() {
      var _this292 = this;
      this.close.on(cc.Node.EventType.TOUCH_END, function () {
        _this292.hide();
      });
    }
  }, {
    key: "hide",
    value: function hide() {
      this.node.active = false;
      if ($2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
        $2pvzChannel.pvzChannel.instance().closeNative("nativeArr1");
        $2pvzChannel.pvzChannel.instance().closeNative("nativeArr2");
      }
    }
  }, {
    key: "init",
    value: function init() {
      var _this293 = this;
      this.isMoving = false;
      $2kc.default.htGetBox($2pvzChannel.pvzChannel.instance().getPara("bid"), function (e, t) {
        if (e) {
          $2kc.default.err(e);
        } else {
          _this293.iconArr = t;
          var _loop13 = function _loop13() {
            var t = _this293.iconArr[_e152];
            cc.assetManager.loadRemote(t.iconUrl, {
              ext: "." + $2kc.default.picType
            }, function (e, a) {
              if (e) {
                $2kc.default.err("加载icon失败:" + t.iconUrl);
                return void $2kc.default.err("" + e);
              }
              var n = new cc.SpriteFrame(a);
              _this293.spMap.set(t.iconUrl, n);
              $2kc.default.log("加载icon成功1:" + t.iconUrl);
            });
          };
          for (var _e152 = 0; _e152 < _this293.iconArr.length; _e152++) {
            _loop13();
          }
          _this293.scheduleOnce(function () {
            _this293.fillContainer(_this293.container);
            _this293.fillContainer(_this293.container2);
          }, 2);
        }
      });
    }
  }, {
    key: "fillContainer",
    value: function fillContainer(e) {
      e.removeAllChildren();
      var t = this.iconArr.length;
      for (var _a73 = 0; _a73 < 9; _a73++) {
        var _n96 = _a73;
        _a73 >= t && (_n96 = _a73 % t);
        var _s21 = this.iconArr[_n96];
        cc.instantiate($2BundleManager.default.instance.getBundleRes("Prefab", "ad/htItem", cc.Prefab)).getComponent($2pvzHtItem.default).set(e, _s21, this);
      }
    }
  }, {
    key: "show",
    value: function show(e) {
      this.node.active = true;
      this.node.parent = e;
      this.isMoving = true;
      if ($2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
        $2pvzChannel.pvzChannel.instance().showNative(null, null, "nativeArr1");
        $2pvzChannel.pvzChannel.instance().showNative(null, null, "nativeArr2");
      }
    }
  }, {
    key: "update",
    value: function update(e) {
      if (this.isMoving) {
        this.container.y += this.moveSpeed;
        this.container2.y += this.moveSpeed;
        if (this.container2.y >= 580) {
          this.container2.y = -580;
        } else {
          this.container.y >= 580 && (this.container.y = -580);
        }
      }
    }
  }]);
  return d;
}(cc.Component);
cc__decorate([ccp_property(cc.Node)], def_pvzHtBoxView.prototype, "close", undefined);
cc__decorate([ccp_property(cc.Node)], def_pvzHtBoxView.prototype, "container", undefined);
cc__decorate([ccp_property(cc.Node)], def_pvzHtBoxView.prototype, "container2", undefined);
def_pvzHtBoxView = cc__decorate([ccp_ccclass], def_pvzHtBoxView);
exports.default = def_pvzHtBoxView;